﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using KOPLibrary.Exceptions;

namespace KOPLibrary.Forms
{
    public partial class ExceptionForm : Form
    {
        bool showDetail = false;
        public ExceptionForm(System.Exception ex,string innerdata)
        {
            InitializeComponent();
            InitUI(ex,innerdata);            
        }

        private void InitUI(System.Exception ex, string innerdata)
        {
            this.Size = new Size(497, 123);
            string temp = ex.Message;
            //temp = temp.Substring(0, temp.IndexOf(Environment.NewLine) + 1);            
            ctlExceptionMessageBox.Text = temp;
            if (!string.IsNullOrEmpty(innerdata)) showDetail = true;
            if (showDetail)
            {
                ctlDetailsButton.Visible = true;
            }
            ctlDetailsMessageBox.Text = innerdata;
            ctlExceptionMessageBox.Select(ctlExceptionMessageBox.Text.Length, 0);            
        }

        private void ctlDetailsButton_Click(object sender, EventArgs e)
        {
            if (ctlDetailsPanel.Visible == false)
            {
                ctlDetailsPanel.Visible = true;
                ctlDetailsButton.Text = "Ayrıntılar <<";
                this.Size = new Size(497, 287);
            }
            else
            {
                ctlDetailsPanel.Visible = false;
                ctlDetailsButton.Text = "Ayrıntılar >>";
                this.Size = new Size(497, 123);
            }
        }
    }
}
